<template>
<view>
	<image class="bgset" src="/static/bg.jpg"></image>
	<view class="header">
		<view class="header_top" @click="searchClick">[{{text}}]统计</view>
		<view class="header_top_two">{{info.company_name}}</view>
		<view class="header_top_three">{{info.oaNum}}</view>
		<view class="header_content">
			<view class="header_init" @click="jump('/manage/money/index')">
				<text class="fontSize1">营业额</text>
				<text class="fontSize1">{{count.money}}</text>
				<text class="fontSize2">{{text}}</text>
			</view>
			<view class="header_init" @click="jump('./mark/index')">
				<text class="fontSize1">预约</text>
				<text class="fontSize1">{{count.mark_count}}</text>
				<text class="fontSize2">{{text}}</text>
			</view>
			<view class="header_init" @click="jump('./my/conn')">
				<text class="fontSize1">消耗</text>
				<text class="fontSize1">{{count.consume_count}}</text>
				<text class="fontSize2">{{text}}</text>
			</view>
		</view>
		<view class="header_footer">
			<view @click="jump('./member/index')">会员总数:{{info.member_count}}人</view>
			<view @click="jump('./member/index')">月度新增:{{info.month_inc}}人</view>
			<view @click="jump('./birthday/index')">生日提醒:{{info.birth_online}}人</view>
		</view>
	</view>
	<view class="search">
		<input disabled placeholder="添加搜索会员" @click="jump('./member/file')"/>
	</view>
	
	<!-- <view class="list_content">
		<view class="list_content_init" @click="jump('./user/index')" v-if="oaRole == 1 || oaRole == 3">
			<image src="/static/system/kh.png"></image>
			<text class="list_content_init_text">员工管理</text>
		</view>
	</view> -->
	
	<view class="content">
		<!--第一行公共全部都可以用-->
		<view class="row">
			<view class="row_init border_right" @click="jump('./center/markTime')">
				<image src="/static/system/mark.png"></image>
				<view class="row_init_content">预约时间表</view>
			</view>
			<view class="row_init border_right" @click="jump('./project/index')">
				<image src="/static/system/card.png"></image>
				<view class="row_init_content">项目管理</view>
			</view>
			<view class="row_init border_right" @click="jump('./goods/index')">
				<image src="/static/system/out.png"></image>
				<view class="row_init_content">库存管理</view>
			</view>
		</view>
		<view class="row">
			<view class="row_init border_right" @click="jump('./member/index')">
				<image src="/static/system/kh_list.png"></image>
				<view class="row_init_content">会员管理</view>
			</view>
			<view class="row_init border_right" @click="jump('./center/index')">
				<image src="/static/system/manualCate.png"></image>
				<view class="row_init_content">数据统计</view>
			</view>
			<view class="row_init border_right" @click="jump('./my/full')">
				<image src="/static/system/service.png"></image>
				<view class="row_init_content">服务评价</view>
			</view>
		</view>
		<view class="row" v-if="oaRole == 1 || oaRole == 3">
			<view class="row_init border_right" @click="jump('./user/index')">
				<image src="/static/system/kh.png"></image>
				<view class="row_init_content">员工管理</view>
			</view>
			<view class="row_init border_right" @click="jump('./daily/index')">
				<image src="/static/system/use.png"></image>
				<view class="row_init_content">日常支出</view>
			</view>
			<view class="row_init border_right" @click="jump('./goods/table')">
				<image src="/static/system/stock_list.png"></image>
				<view class="row_init_content">仓库盘点</view>
			</view>
		</view>
	</view>
	
	<view class="formBg" v-if="searchShow">
		<view class="form">
			<view class="form_title">选择时间</view>
			<view class="form_init" @click="search(1)">今日</view>
			<view class="form_init" @click="search(2)">本月</view>
			<view class="form_init" @click="search(3)">本年</view>
			<view class="form_list">
				<picker mode="date" :value="sdate" @change="bindDate" data-key="sdate">
					<view class="uni-input weui-input">{{sdate ? sdate : '选择日期'}}</view>
				</picker>
				--
				<picker mode="date" :value="edate" @change="bindDate" data-key="edate">
					<view class="uni-input weui-input">{{edate ? edate : '选择日期'}}</view>
				</picker>
				<view class="btn" @click="select">确定</view>
			</view>
		</view>
	</view>
</view>
</template>

<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			//oaRole 1:店长2:员工3:商户
			oaRole:0,
			info:{},
			count:[],
			text:'今日',
			sdate:'',
			edate:'',
			searchShow:false,
			type:1
		}
	},
	onLoad:function(){
		uni.showLoading({
			title:'加载中'
		})
		this.getInfo();
		this.getCount();
		this.oaRole = uni.getStorageSync('oaRole')
	},
	methods: {
		getCount:function(){
			var data = {
				oa_id:uni.getStorageSync('oa_id'),
				type:this.type
			}
			var that = this
			request({
				url: '/manage/company/count',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading()
					that.count = res.data.data
				},
			})
		},
		getInfo:function(id){
		    var data = {
		        'oa_id':uni.getStorageSync('oa_id')
		    }
		    var that = this
			request({
				url: '/manage/company/info',
				method: 'get',
				data:data,
				success: (res) => {
					that.info = res.data.data
				},
			})
		},
		jump:function(url){
			if(uni.getStorageSync('oaRole') == 2){
				switch(url){
					case '/manage/money/index':{}
					uni.showToast({
						title: '暂无权限!!',
						icon: "none", 
						position:'bottom',
					});
					return;
				}
			}
			uni.navigateTo({
			  url:url
			})
		},
		search:function(key){
			this.type = key
			if(key == 1){
				this.text = '今日'
			}
			if(key == 2){
				this.text = '本月'
			}
			if(key == 3){
				this.text = '本年'
			}
			this.searchShow = false
			uni.showLoading({
				title:'加载中'
			})
			this.getCount()
		},
		jumpUser:function(url,key){
			uni.navigateTo({
			  url:url+'?key='+key
			})
		},
		bindDate:function(e){
			let key = e.currentTarget.dataset.key
			let value = e.detail.value
			this[key] = value
		},
		select:function(){
			if(!this.sdate || !this.edate){
				uni.showToast({
					title: '请选择日期!!',
					icon: "none", 
					position:'bottom',
				});
				return;
			}
			this.searchShow = false
			this.text = '自定义'
			uni.showLoading({
				title:'加载中'
			})
			this.getSearch()
		},
		getSearch:function(){
			var data = {
				oa_id:uni.getStorageSync('oa_id'),
				sdate:this.sdate,
				edate:this.edate
			}
			var that = this
			request({
				url: '/manage/company/search',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading()
					that.count = res.data.data
				},
			})
		},
		searchClick:function(){
			this.searchShow = true
		}
	}
}
</script>

<style>
@import url("./css/index.css");
</style>
